package com.atguigu.gmall.common.config.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author:hrh
 * @create: 2022-11-03 16:24
 * @Description: Minio Bean
 */
@Configuration
@EnableConfigurationProperties(AppMinioProperties.class)
public class AppMinioAutoConfiguration {
  /*  @Value ("${app.minio.endpoint}")
    String endpoint;

    @Value ("${app.minio.access_Key}")
    String ak;

    @Value ("${app.minio.secret_Key}")
    String sk;

    @Value ("${app.minio.bucket}")
    String bucketName;*/

    @Autowired
    AppMinioProperties appMinioProperties;

    @Bean
    public MinioClient minioClient() throws Exception {
        //MinioClient minioClient = new MinioClient (endpoint,ak,sk);
        MinioClient minioClient = new MinioClient (appMinioProperties.endpoint, appMinioProperties.accessKey, appMinioProperties.secretKey);

        return minioClient;
    }
}
